import axios from "@/utils/axios"
import { buildDeptTree, buildDeptList } from './lib'

export default <Service>{

  async view(data) {
    const response = await axios({
      url: '/system/dept/list',
      method: 'GET',
      data
    })
    return buildDeptTree(response.data)
  },

  async list(data) {
    const response = await axios({
      url: '/system/dept/list',
      method: 'GET',
      data
    })
    return buildDeptList(response.data)
  },

  update(data) {
    return axios({
      url: '/system/dept',
      method: 'PUT',
      data
    })
  },

  insert(data) {
    return axios({
      url: '/system/dept',
      method: 'POST',
      data
    })
  },

  remove({ id }) {
    return axios({
      url: `/system/dept/${id}`,
      method: 'DELETE'
    })
  }
}